package com.xinqi.modules.prepare.folder.service;

import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.Param;
import com.xinqi.common.base.dto.CommonFileDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderCopyDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderCreateDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderDeleteDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderMoveDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderQueryDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileFolderUpdateDTO;
import com.xinqi.modules.prepare.folder.dto.req.PrepareFileShareURLDto;
import com.xinqi.modules.prepare.folder.dto.rsp.PrepareFileFolderResultDTO;
import com.xinqi.modules.prepare.prepare.enums.PrepareFileTypeEnum;
import com.xinqi.modules.prepare.prepare.enums.PrepareTypeEnum;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.Valid;
import java.util.List;

/**
 * 备课区文件夹服务层
 *
 * @author: system
 * @date: 2023/03/19
 */
public interface PrepareFileFolderService {
    /**
     * 分页查询 备课区文件夹数据
     */
    PageInfo<PrepareFileFolderResultDTO> page(Param pageable, PrepareFileFolderQueryDTO query);

    /**
     * 查询 备课区文件夹数据
     */
    List<PrepareFileFolderResultDTO> find(PrepareFileFolderQueryDTO query);

    /**
     * 根据id查询 备课区文件夹数据
     */
    PrepareFileFolderResultDTO findById(Long id);

    /**
     * 新增 备课区文件夹数据
     */
    Long insert(@Valid PrepareFileFolderCreateDTO dto);

    Boolean isExistName(Long prepareId, PrepareTypeEnum type, String name, Long pid, PrepareFileTypeEnum fileType, Long oId);

    /**
     * 根据id修改 备课区文件夹数据
     */
    Boolean updateFolderById(@Valid PrepareFileFolderUpdateDTO dto);

    /**
     * 根据id删除 备课区文件夹数据
     */
    Boolean deleteById(Long id);

    /**
     * 根据id删除 备课区文件夹数据
     */
    @Transactional(rollbackFor = Exception.class)
    Boolean deleteById(PrepareFileFolderDeleteDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean move(@Valid PrepareFileFolderMoveDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean copy(@Valid PrepareFileFolderCopyDTO dto);

    List<CommonFileDTO> download(Long id);

    String generateShareUrl(PrepareFileShareURLDto dto);

    String visitShareContent(PrepareFileShareURLDto dto);

    List<PrepareFileFolderResultDTO> tree(PrepareFileFolderQueryDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean batchDelete(Long prepareId, List<Long> idList);

    @Transactional(rollbackFor = Exception.class)
    Boolean batchMove(List<PrepareFileFolderMoveDTO> dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean batchCopy(List<PrepareFileFolderCopyDTO> dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean savToPrepare(PrepareFileFolderCopyDTO dto);
}
